package object_Test;

public class cloneable {
    public static void main(String[] args) {
        Animal animal1=new Animal("张三");
        Animal animal2=animal1.clone();
        Animal animal3=new Animal("张三");
        System.out.println(animal1==animal2);
        System.out.println(animal2.name);
        System.out.println(animal3.name);
    }
}

class Animal implements Cloneable{
    String name;

    public Animal(String name) {
        this.name = name;
    }

    @Override
    public Animal clone(){
        Animal newAnimal=null;
        try {
            newAnimal=(Animal) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
        return newAnimal;
    }
}